package com.x.dictionary.service;

/**
 * @author xlh
 */
public class DictionaryTest {
    public static void main(String[] args) {
        // 获取字典服务
        DictionaryService dictionary = DictionaryService.getService();
        // 检索
        System.out.println(DictionaryTest.lookup(dictionary, "book"));
        System.out.println(DictionaryTest.lookup(dictionary, "editor"));
        System.out.println(DictionaryTest.lookup(dictionary, "xml"));
        System.out.println(DictionaryTest.lookup(dictionary, "REST"));
    }

    public static String lookup(DictionaryService dictionary, String word) {
        String outputString = word + ": ";
        String definition = dictionary.getDefinition(word);
        if (definition == null) {
            return outputString + "Cannot find definition for this word.";
        } else {
            return outputString + definition;
        }
    }
}
